package com.mooc.yohoshop.ui.home;

import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;

import com.blankj.utilcode.util.LogUtils;
import com.mooc.yohoshop.R;
import com.mooc.yohoshop.entity.BannerEntity;
import com.mooc.yohoshop.imgload.ImageLoad;
import com.youth.banner.adapter.BannerAdapter;

import org.jetbrains.annotations.NotNull;

import java.util.List;

import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;

public class HomeBannerAdapter extends BannerAdapter<BannerEntity.Values, HomeBannerAdapter.BannerVH> {

    public HomeBannerAdapter(List<BannerEntity.Values> datas) {
        super(datas);
    }

    @Override
    public BannerVH onCreateHolder(ViewGroup parent, int viewType) {
        View itemView = LayoutInflater.from(parent.getContext()).inflate(R.layout.item_banner,parent,false);
        return new BannerVH(itemView);
    }

    @Override
    public void onBindView(BannerVH holder, BannerEntity.Values data, int position, int size) {
        ImageLoad.loadMatch(data.recommend_url,holder.img);
    }

    public static class BannerVH extends RecyclerView.ViewHolder{
        ImageView img;
        public BannerVH(@NonNull @NotNull View itemView) {
            super(itemView);
            img = itemView.findViewById(R.id.home_banner_img);
        }
    }

}
